<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>P75 4.1.4【案例】字符串大小写转换</title>
</head>

<body>
    <h2>大小写转换</h2>
    原数据：<input id="old" type="text">
    操 作：
    <input type="button" value="转大写" onclick="deal('upper')">
    <input type="button" value="转小写" onclick="deal('lower')">
    新数据：<input id="new" type="text">
    <script>
        function deal(opt) {
            var str = document.getElementById('old').value;
            switch (opt) {
                case 'upper':
                    str = str.toUpperCase();
                    break;
                case 'lower':
                    str = str.toLowerCase();
                    break;
            }
            document.getElementById('new').value = str;
        }
    </script>
    <a href="../首页/page04.html">
        <h2>返回上一页面</h2>
    </a>
</body>

</html>